﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Consulta;

namespace Log4Net
{
    class Log : ILog
    {
        private IConsultas consulta;
        private static Log instance = null;



        private Log()
        {
            consulta = FactoryConsulta.getInstanceConsulta();
        }

        public static Log getInstancia()
        {
            if (instance == null)
                instance = new Log();
            return instance;
        }


        public void info(int idUsuario, string texto)
        {
            try
            {
                consulta.agregarLog(DateTime.Now, idUsuario, texto, "INFO");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void warn(int idUsuario, string texto)
        {
            try
            {
                consulta.agregarLog(DateTime.Now, idUsuario, texto, "WARN");
            }            
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void error(int idUsuario, string texto)
        {
            try
            {
                consulta.agregarLog(DateTime.Now, idUsuario, texto, "ERROR");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
